﻿using UnityEngine;
using System.Collections;
using iTManager;

public class LoadingLevel : MonoBehaviour {
    [SerializeField]
    private GameObject loadingScreen;
    private AsyncOperation asyn;
    void Start()
    {

        loadingScreen.transform.position = new Vector3(0.0415802f, -0.06253624f, -2);
        loadingScreen.transform.localScale = new Vector3(2, 2, 1);
        asyn = Application.LoadLevelAsync("Level1");
        asyn.allowSceneActivation = false;
        LoadingScreen();
    }
    private GameObject Fade;
    private void LoadingScreen()
    {
        Fade = iTManager.iTweenBase.CameraFadeAdd() ?? GameObject.Find("iTween Camera Fade");
        Fade.layer = LayerMask.NameToLayer("UI");
        iTManager.iTweenBase.CameraFadeTo(new iTManager.CameraFadeTo()
        {
            delay = 0f,
            amount_float = 0.2f,
            time = 1f,
            easetype = iTManager.iTweenBase.EaseType.linear
        }).OnComplete(() =>
        {
            gameObject.SetActive(false); Fade.SetActive(false);
            asyn.allowSceneActivation = true;

        }).Start();
    }
	
}
